home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Amiga Classic Collection
/
The Amiga Classic Collection - Disc 1.iso
/
Education
/
ED05-AmRadio1.DMS
/
ED05-AmRadio1.adf
/
Terminal Progs
/
N3ETerm
/
P81.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-01-19
|
21KB
|
1,195 lines
* P81.ASM 092886
NOPAGE
INCLUDE "A:SYSBASE.LVO"
_AbsExecBase equ 4
startup: ; reference for Wack users
MOVE.L _AbsExecBase,A6 $4,A6
SUBA.L A1,A1
JSR _LVOFindTask(A6)
MOVE.L D0,A4
LEA.L DOSName(PC),A1
MOVEQ.L #0,D0 Lib version
JSR _LVOOpenLibrary(A6)
MOVE.L D0,A5
BEQ RTS1 DOSERROR
BSR _main call C main entry
MOVEQ.L #0,D0 return success code
RTS1
RTS
WD EQU 640
HT EQU 200
CAPSIZE EQU 4096
CAPTURE EQU -1 .B
send EQU -2 .B
sendok EQU -3 .B
brate EQU -4 .B
newcall EQU -5 .B
MON EQU -6 .B
VARi EQU -8 .W
SENCNT EQU -10 .W
FHCAPT EQU -14 .L
FHSEND EQU -18 .L
R_R EQU -22 .L
W_R EQU -26 .L
rs_in EQU -28 .W
rs_out EQU -30 .W
N_M EQU -34 .L
SENPNT EQU -38 .L
xname EQU SENPNT-32
name EQU xname-32
rbuff EQU name-512
cbuff EQU rbuff-512
BUFCAP EQU cbuff-CAPSIZE
BUFSEN EQU BUFCAP-512
_main
LEA INTU_LIB(PC),A1
JSR _LVOOpenLibrary(A6)
MOVE.L D0,_IntuitionBase
BEQ EXIT1
LEA GRAP_LIB(PC),A1
JSR _LVOOpenLibrary(A6)
MOVE.L D0,_GfxBase
BEQ EXIT1
LINK A4,#BUFSEN
MOVEM.L D2/D7,-(A7)
MOVEQ #1,D1
CLR.W name(A4)
CLR.W VARi(A4)
CLR.B send(A4)
CLR.B CAPTURE(A4)
MOVE.B D1,MON(A4)
MOVE.B D1,brate(A4)
MOVE.B D1,sendok(A4)
*if(!(mywindow=(struct Window *)OpenWindow(&NewWindow)))
MOVE.L A6,-(A7)
MOVEA.L _IntuitionBase(PC),A6
LEA NewWindow(PC),A0
JSR _LVOOpenWindow(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,mywindow
BEQ EXIT1
*Read_Request=
*(struct IOExtSer *)AllocMem(sizeof(*Read_Request),MEMF_PUBLIC|MEMF_CLEAR)
BSR DO_Alloc
MOVE.L D0,R_R(A4)
*Read_Request->io_SerFlags=SERF_SHARED | SERF_XDISABLED
MOVEA.L D0,A0
MOVE.B #$A0,$4F(A0)
*Read_Request->IOSer.io_Message.mn_ReplyPort=CreatePort("Read_RS",0)
LEA MRead_RS(PC),A0
BSR DoCreate
MOVEA.L R_R(A4),A1
MOVE.L D0,$0E(A1)
*if(OpenDevice(SERIALNAME,NULL,Read_Request,NULL))
BSR OPEN_SERIAL
BNE ENDALL goto endall
*Read_Request->IOSer.io_Command=CMD_READ
*Read_Request->IOSer.io_Length=1
*Read_Request->IOSer.io_Data=(APTR) &rs_in[0]
MOVEA.L R_R(A4),A0
MOVE.W #2,$1C(A0)
MOVEQ #1,D0
MOVE.L D0,$24(A0)
LEA rs_in(A4),A1
MOVE.L A1,$28(A0)
*Write_Request=(struct IOExtSer *)AllocMem(sizeof(*Write_Request),MEMF_PUBLIC|MEMF_CLEAR);
*Write_Request->io_SerFlags=SERF_SHARED | SERF_XDISABLED
BSR DO_Alloc
MOVE.L D0,W_R(A4)
MOVEA.L D0,A0
MOVE.B #$A0,$4F(A0)
*Write_Request->IOSer.io_Message.mn_ReplyPort=CreatePort("Write_RS",0)
LEA MWrite_RS(PC),A0
BSR DoCreate
MOVEA.L W_R(A4),A1
MOVE.L D0,$E(A1)
*if(OpenDevice(SERIALNAME,NULL,Write_Request,NULL))
BSR OPEN_SERIAL
BNE ENDALL goto endall
*Write_Request->IOSer.io_Command=CMD_WRITE
MOVEA.L W_R(A4),A0
MOVE.W #3,$1C(A0)
*Write_Request->IOSer.io_Length=1
MOVEQ #1,D0
MOVE.L D0,$24(A0)
*Write_Request->IOSer.io_Data=(APTR) &rs_out[0]
LEA rs_out(A4),A1
MOVE.L A1,$28(A0)
*SetAPen(mywindow->RPort,1)
BSR PENSET1
*Read_Request->io_SerFlags=SERF_SHARED | SERF_XDISABLED
MOVEA.L R_R(A4),A0 ??
MOVE.B #$A0,$4F(A0) ??
*Read_Request->io_ReadLen=8
MOVEQ #8,D0
MOVE.B D0,$4C(A0)
*Read_Request->io_WriteLen=8
MOVE.B D0,$4D(A0)
*Read_Request->io_CtlChar=1L
MOVEQ #1,D0
MOVE.L D0,$30(A0)
MOVE.L #1200,D0 1200 Baud to start
BSR DO_RR_BEGIN
***
MAIN ;main loop
***
* /* wait for window/serial port message */
* Wait((1<<Read_Request->IOSer.io_Message.mn_ReplyPort->
* mp_SigBit) | (1<<mywindow->UserPort->mp_SigBit))
MOVEA.L R_R(A4),A1
MOVEA.L $E(A1),A0
MOVEQ #0,D1
MOVE.B $F(A0),D1
MOVEQ #1,D0
ASL.L D1,D0
MOVEA.L mywindow(PC),A1
MOVEA.L $56(A1),A0
MOVEQ #0,D1
MOVE.B $F(A0),D1
MOVEQ #1,D2
ASL.L D1,D2
OR.L D2,D0
JSR _LVOWait(A6)
* while(CheckIO(Read_Request))
CKIO
MOVE.L R_R(A4),A1
JSR _LVOCheckIO(A6)
TST.L D0
BEQ CKKEY
* {WaitIO(Read_Request)
MOVE.L R_R(A4),A1
JSR _LVOWaitIO(A6)
* c=rs_in[0] & 0x7F;
MOVE.B rs_in(A4),D7
ANDI.B #$7F,D7
BSR BeginIO_RR
CMPI.B #$A,D7
BEQ.S CKIO
CMPI.B #$D,D7
BNE.S L2B8
MOVE.B #$A,D7
L2B8
TST.B send(A4)
BEQ.S L2C8
CMPI.B #$13,D7 ^S
BNE.S L2C8
CLR.B sendok(A4)
L2C8
CMPI.B #$11,D7 ^Q
BNE.S L2D4
MOVE.B #1,sendok(A4)
* if (c==7) emit(c);
L2D4
CMPI.B #7,D7
BNE.S L2EC
BSR EMITD7
* if ((c>31 && c<127) || (c>=8 && c<=10))
L2EC
CMPI.B #$1F,D7
BLS.S L2F8
CMPI.B #$7F,D7
BCS.S L300
L2F8
CMPI.B #8,D7 Drop ^ chars
BCS CKIO
CMPI.B #$A,D7
BHI CKIO
* if (!mon) emit(c);
L300
TST.B MON(A4)
BNE.S FILL
BSR EMITD7
***
FILL ;rbuff with line of text
***
MOVE.W VARi(A4),D0 i
CMPI.B #8,D7 c=8?
BNE.S FILL1
SUBQ.W #1,VARi(A4) i-
BPL CKIO
BRA ENDI
FILL1
CMPI.W #512,D0 i=549?
BEQ CKIO
LEA rbuff(A4),A0
ADDA.W D0,A0
MOVE.B D7,(A0)+
ADDQ.W #1,D0 i+
MOVE.W D0,VARi(A4)
CMPI.B #$A,D7 c=10?
BNE CKIO
CLR.B (A0) (i)=0
TST.B MON(A4)
BEQ MONMODE
SUBQ.W #1,D0
BEQ ENDI i=0 and c=LF ?
***
*ISCALL ; Does rbuff contain a call string
***
CLR.B newcall(A4)
MOVEQ #0,D0
LEA rbuff(A4),A0
ISCALL1
ADDQ.L #1,D0
MOVE.B (A0)+,D7
BEQ.S MONMODE c=0
CMPI.B #'-',D7 c=invalid
BLT.S MONMODE
CMPI.B #4,D0 i<5
BLT.S ISCALL1
CMPI.B #9,D0 i>9
BGT.S MONMODE
CMPI.B #'>',D7 c=>
BNE.S ISCALL1
***
* NEWCALL- not same call
***
LEA rbuff(A4),A0
LEA cbuff(A4),A1
NEWCALL1
CMPM.B (A0)+,(A1)+
BNE.S NEWCALL2
TST.B -1(A0)
BNE.S NEWCALL1
BRA.S ENDI
NEWCALL2
CMPI.B #'*',-1(A0)
BEQ.S ENDI
CMPI.B #'*',-1(A1)
BEQ.S ENDI
* MOVE.B #1,newcall(A4)
ST newcall(A4)
***
* CALL - update call buffer
***
LEA rbuff(A4),A0
LEA cbuff(A4),A1
CALL
MOVE.B (A0)+,(A1)+
BNE.S CALL
***
MONMODE ; to screen & capture
***
TST.B MON(A4)
BEQ.S CAPMODE
TST.B newcall(A4)
BEQ.S MONMODE1
MOVEQ #$A,D7
BSR EMITD7
BSR DOCAP
MONMODE1
LEA rbuff(A4),A0
BSR EMITS
CAPMODE
TST.B CAPTURE(A4)
BEQ.S ENDI
PEA rbuff(A4)
CAPMODE1
MOVEA.L (A7),A0
MOVE.B (A0)+,D7
BEQ.S ENDB
MOVE.L A0,(A7)
BSR DOCAP
BRA.S CAPMODE1
ENDB
MOVE.L (A7)+,A0
ENDI
CLR.W VARi(A4)
BRA CKIO
***
CKKEY ;Check for keyboard or mouse or send
***
MOVE.B send(A4),D0
AND.B sendok(A4),D0
BEQ.S NXT_MSG
BSR GET_SEND_CHAR Get char from READ file & send serial
* while(NewMessage=(struct IntuiMessage *)GetMsg(mywindow->UserPort))
NXT_MSG
BSR GET_MSG
BEQ MAIN
* switch(NewMessage->Class)
MOVEA.L N_M(A4),A0
MOVE.L $14(A0),D0
CMPI.W #$200,D0
BEQ ENDALL
CMPI.W #$400,D0
BNE.S NXT_MSG
* User hit key *
MOVEQ #0,D0
MOVE.B D7,D0
CMPI.B #$59,D7
BEQ ENDALL L826
CMPI.B #$55,D7
BEQ DO_NEWCLI
CMPI.B #$5F,D7
BEQ HELP_KEY
CMPI.B #$54,D7
BEQ F5_KEY
CMPI.B #$52,D7
BEQ F3_KEY
CMPI.B #$51,D7
BEQ F2_KEY
CMPI.B #$50,D7
BNE SEND_SERIAL
* case 80: /* F1 KEY */
TST.B CAPTURE(A4)
BEQ.S OPENCAP
BSR CLOSECAP
BRA NXT_MSG
***
OPENCAP ;Open Capture buffer
***
LEA MCAPTURE(PC),A0
BSR EMITS
PEA name(A4)
BSR FILENAME
ADDQ.L #4,A7
MOVE.L #1006,D2
LEA name(A4),A0
MOVE.L A0,D1
JSR _LVOOpen(A5)
MOVE.L D0,FHCAPT(A4)
BEQ DOMERROR
ST CAPTURE(A4)
BRA NXT_MSG
***
F2_KEY ;Open/close read file to send serial
***
TST.B send(A4)
BEQ.S NEW_READ
BSR CLOSESEND
LEA SENDCAN(PC),A0
BSR EMITS
BRA NXT_MSG
NEW_READ
LEA MSEND(PC),A0
BSR EMITS
PEA xname(A4)
BSR FILENAME
ADDQ.L #4,A7
*** OPEN READ FILE TO SEND CHARS OVER SERIAL
MOVE.L #1005,D2
LEA xname(A4),A0
MOVE.L A0,D1
JSR _LVOOpen(A5)
MOVE.L D0,FHSEND(A4)
BEQ DOMERROR
CLR.W SENCNT(A4)
ST send(A4)
BRA NXT_MSG
***
F3_KEY ;Next lower Baud rate
***
* AbortIO(Read_Request)
MOVE.L R_R(A4),A1
JSR _LVOAbortIO(A6)
MOVEQ #0,D0
MOVE.B brate(A4),D0
SUBQ #1,D0
BGE L710
MOVEQ #2,D0
L710
MOVE.B D0,brate(A4)
* Read_Request->io_Baud=(bratev[brate])
ASL.W #1,D0
LEA bratev(PC),A0
MOVE.W 0(A0,D0.W),D0
BSR DO_RR_BEGIN
BRA.S HELP_KEY
***
F5_KEY ;Toggle MON mode
***
EOR.B #1,MON(A4)
***
HELP_KEY
***
LEA MONON(PC),A0
TST.B MON(A4)
BNE.S HELP1
LEA MONOFF(PC),A0
HELP1
BSR EMITS
LEA name(A4),A0
BSR EMITS
LEA MOPEN(PC),A0
TST.B CAPTURE(A4)
BNE.S HELP2
LEA MCLOSED(PC),A0
HELP2
BSR EMITS
* emits(brates[brate])
MOVEQ #0,D0
MOVE.B brate(A4),D0
ASL.L #2,D0
ADD.B brate(A4),D0
MOVEA.L D0,A0
ADDA.L #brates,A0
BSR EMITS
LEA MHELP(PC),A0
BSR EMITS
BRA NXT_MSG
***
DO_NEWCLI
***
LEA NEWCLI(PC),A0
MOVE.L A0,D1
CLR.L D2
CLR.L D3
JSR _LVOExecute(A5)
BNE NXT_MSG
***
DOMERROR ;Print *** ERROR
***
BSR DOMERR1
BRA NXT_MSG
***
SEND_SERIAL ;D7 to serial
***
BSR TOASC
BEQ NXT_MSG
BSR WRITE1
BRA NXT_MSG
***
ENDALL ;Clean up and exit program
***
BSR CLOSECAP
BSR CLOSESEND
MOVE.L R_R(A4),A1
JSR _LVOCloseDevice(A6)
*DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort)
MOVEA.L R_R(A4),A0
BSR DELETEPORT
*FreeMem(Read_Request,sizeof(*Read_Request))
MOVEQ #$52,D0
MOVE.L R_R(A4),A1
JSR _LVOFreeMem(A6)
*CloseDevice(Write_Request)
MOVE.L W_R(A4),A1
JSR _LVOCloseDevice(A6)
*DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort)
MOVEA.L W_R(A4),A0
BSR DELETEPORT
*FreeMem(Write_Request,sizeof(*Write_Request))
MOVEQ #$52,D0
MOVE.L W_R(A4),A1
JSR _LVOFreeMem(A6)
*CloseWindow(mywindow);
MOVE.L A6,-(A7)
MOVEA.L _IntuitionBase(PC),A6
MOVE.L mywindow(PC),A0
JSR _LVOCloseWindow(A6)
MOVEA.L (A7)+,A6
MOVEQ #0,D1 exit(0)
EXITX
JSR _LVOExit(A5) gone
EXIT1
MOVEQ #1,D1
BRA.S EXITX
***
EMITD7 ;Emit char in D7
***
MOVE.L D7,-(A7)
BSR EMITC
ADDQ.L #4,A7
RTS
***
TOASC ;Convert keycode in D7 to ascii
***
MOVEQ #0,D0
LEA KEYS(PC),A1
CMPI.B #75,D7 if (code<75)
BCC.S NO_CONVERT
ADD.B SHIFT-KEYS(A1),D7 if (shift) code+=75
MOVEA.L A1,A0
ADDA.L D7,A0 c=keys[code]
MOVE.B (A0),D0
CMPI.B #'a',D0 if (c>='a' && c<='z')
BCS.S TOASCRET
CMPI.B #'z',D0
BHI.S TOASCRET
TST.B CTRL-KEYS(A1) if (ctrl)
BEQ.S TOASC1
SUB.B CTRL-KEYS(A1),D0 c-=96
BRA.S TOASCRET
TOASC1
SUB.B CAPSL-KEYS(A1),D0 c-=32
BRA.S TOASCRET
NO_CONVERT
CMPI.B #96,D7 if (code>=96 && code<=97) shift=1
BCS.S TOASC3
CMPI.B #97,D7
BHI.S TOASC3
MOVE.B #75,SHIFT-KEYS(A1)
TOASC3
CMPI.B #98,D7 if (code=98) capsl=1
BNE.S TOASC4
MOVE.B #32,CAPSL-KEYS(A1)
TOASC4
CMPI.B #99,D7 if (code=99) ctrl=1
BNE.S TOASC5
MOVE.B #96,CTRL-KEYS(A1)
TOASC5
CMPI.B #224,D7 if (code>=224 && code<=225)
BCS.S TOASC6
CMPI.B #225,D7
BHI.S TOASC6
CLR.B SHIFT-KEYS(A1)
TOASC6
CMPI.B #226,D7 if (code=226) capsl=0
BNE.S TOASC7
CLR.B CAPSL-KEYS(A1)
TOASC7
CMPI.B #227,D7 if (code=227) ctrl=0
BNE.S TOASCRET
CLR.B CTRL-KEYS(A1)
TOASCRET
MOVE.L D0,D7
RTS
***
EMITS ;Emit String of text to screen
***
MOVE.B (A0)+,D0
BEQ.S LRETURN
MOVE.L A0,-(A7)
MOVE.L D0,-(A7) emit(c);
BSR EMITC
ADDQ.L #4,A7
MOVE.L (A7)+,A0
BRA.S EMITS
LRETURN
RTS
***
FILENAME ; get name
***
CLR.L -(A7) i=0
FILENAME1
* if (NewMessage=(struct IntuiMessage *)GetMsg(mywindow->UserPort))
BSR GET_MSG
BEQ FILENAME1
* c=toasc(NewMessage->Code)
* MOVE.L (A7)+,A0 NewMessage
* MOVE.W $18(A0),D7 W/B ??
BSR TOASC
CMPI.B #13,D7 if (c==13)
BNE.S FILENAME2
MOVE.L D7,-(A7) emit(c)
BSR EMITC
ADDQ.L #4,A7
MOVEA.L 8(A7),A0 name[i]=0
ADDA.L (A7),A0 i
CLR.B (A0)
BRA.S FRETURN
FILENAME2
CMPI.B #32,D7 if (c>=32)
BCS.S FILENAME3
MOVEA.L 8(A7),A0 name[i]=c
ADDA.L (A7),A0 i
MOVE.B D7,(A0) put in name
MOVE.L D7,-(A7)
BSR EMITC
ADDQ.L #4,A7
ADDQ.L #1,(A7) i+=1
BRA.S FILENAME1
FILENAME3
CMPI.B #8,D7 if (c==8 && i)
BNE.S FILENAME1
TST.L (A7)
BEQ.S FILENAME1
LEA BSPACE(PC),A0 emits(8,32,8,0)
BSR EMITS
SUBQ.L #1,(A7) i-=1
BRA FILENAME1
FRETURN ADDQ.L #4,A7
RTS
***
EMITC ;Emit character to screen
***
LINK A4,#-4
MOVEM.L A3/A6/D2/D5-D7,-(A7)
MOVE.B 11(A4),D7
BEQ EMITRTS
MOVE.W CX,D6 x=cx
MOVE.W CY,D5 y=cy
MOVEA.L mywindow(PC),A3
MOVE.L $32(A3),A3
* Remove cursor
MOVEQ #2,D0 COMPLEMENT
BSR DRMDSET
BSR CURNORM
MOVEQ #1,D0 JAM2
BSR DRMDSET
* switch(c)
MOVE.B D7,D0
SUBI.B #7,D0
BLT.S CASEDEF
CMPI.B #7,D0
BGE.S CASEDEF
ASL.L #1,D0
JMP JMPTAB(PC,D0)
JMPTAB
BRA.S CASE7 7
BRA.S CASE8 8
BRA.S CASE9 9
BRA.S CASE10 10
BRA.S CASEDEF 11
BRA.S CASE12 12
BRA.S CASE10 13
* ClipBlit(mywindow->RPort,0,0,mywindow->RPort,0,y-6,WD,HT,0x50)
CASE7
MOVEM.L D5/A6,-(A7)
MOVE.L D5,D3 y
SUBQ.L #6,D3 y-6
MOVEQ.L #$50,D6 $50
MOVE.L #HT,D5 HT
MOVE.L #WD,D4 WD
CLR.L D2 0
MOVE.L A3,A1
CLR.L D1 0
CLR.L D0 0
MOVE.L A3,A0
MOVEA.L _GfxBase(PC),A6
JSR _LVOClipBlit(A6)
MOVEM.L (A7)+,D5/A6
BRA.S LB18
CASE8
SUBQ.W #8,D6 x-=8;
CMPI.W #1,D6 if (x<1)
BGE.S LB18
MOVEQ #0,D6 x=0
BRA.S LB18
CASE9
ADDI.W #40,D6 x+=40
BRA.S LB18
CASE12
MOVEQ #0,D6 x=0
MOVEQ #6,D5 y=6
BRA.S LB18
CASE10
MOVEQ #0,D6 x=0
ADDQ.W #8,D5 y+=8
BRA.S LB18
CASEDEF
MOVEQ #1,D0 Text(mywindow->RPort,&cc,1)
LEA.L 11(A4),A0 Point to byte c
MOVE.L A3,A1
MOVE.L A6,-(A7)
MOVE.L _GfxBase(PC),a6
JSR _LVOText(A6)
MOVEA.L (A7)+,A6
ADDQ.W #8,D6 x+=8
* cursor *
LB18
CMPI.W #WD,D6 if (x>(WD-_3))
BLE.S LB22
MOVEQ #0,D6 {x=0;
ADDQ.W #8,D5 y=y+8;}
LB22
CMPI.W #HT-2,D5 if (y>(HT-2))
BLE.S LB58
MOVEQ #0,D6 {x=0;
SUBQ.W #8,D5 y-=8;
MOVEM.L D5/A6,-(A7)
MOVE.L #HT,D5 ScrollRaster(mywindow->RPort,0,8,0,0,WD,HT);}
MOVE.L #WD,D4
CLR.L D3
CLR.L D2
MOVEQ #8,D1
CLR.L D0
MOVE.L A3,A1
MOVE.L _GfxBase(PC),A6
JSR _LVOScrollRaster(A6)
MOVEM.L (A7)+,D5/A6
LB58 ;Move(mywindow->RPort,x,y);
MOVE.L D5,D1
MOVE.L D6,D0
MOVE.L A3,A1
MOVE.L A6,-(A7)
MOVEA.L _GfxBase(PC),A6
JSR _LVOMove(A6)
MOVEA.L (A7)+,A6
* Put cursor
BSR CURNORM
MOVE.W D6,CX cx=x
MOVE.W D5,CY cy=y
EMITRTS
MOVEM.L (A7)+,A3/A6/D2/D5-D7
UNLK A4
RTS
* SetDrMd(mywindow->RPort,??);
***
DRMDSET ;Set Drawing Mode
***
MOVE.L A6,-(A7)
MOVE.L A3,A1
MOVEA.L _GfxBase(PC),A6
JSR _LVOSetDrMd(A6)
MOVEA.L (A7)+,A6
RTS
CURNORM
MOVEQ #3,D0
BSR PENSET
BSR FILLRECT
PENSET1
MOVEQ #1,D0
* SetAPen(mywindow->RPort,??)
***
PENSET ;Set Pen type
***
MOVE.L A6,-(A7)
MOVE.L A3,A1
MOVEA.L _GfxBase(PC),A6
JSR _LVOSetAPen(A6)
MOVEA.L (A7)+,A6
RTS
* RectFill(mywindow->RPort,x,y-6,x+6,y+1)
***
FILLRECT ;Fill Rectangle
***
MOVE.L D6,D2 x
MOVE.L D5,D1 y
SUBQ.L #6,D1 y-6
ADDQ.L #6,D2 x+6
MOVE.L D5,D3
ADDQ.L #1,D3 y+1
MOVE.L D6,D0 x
MOVE.L A3,A1
MOVE.L A6,-(A7)
MOVEA.L _GfxBase(PC),A6
JSR _LVORectFill(A6)
MOVEA.L (A7)+,A6
RTS
***
DO_RR_BEGIN
***
MOVE.L R_R(A4),A1
MOVE.L D0,$3C(A1) io_Baud=1200
MOVE.W #$B,$1C(A1) IOSer.io_Command=SDCMD_SETPARAMS
JSR _LVODoIO(A6)
MOVEA.L R_R(A4),A0
MOVE.W #2,$1C(A0) IOSER.io_Command=CMD_READ
***
BeginIO_RR ;BeginIO(Read_Request)
***
MOVE.L R_R(A4),A1
MOVE.L A6,-(A7)
MOVEA.L $14(A1),A6
JSR -$1E(A6) ?? FFE2
MOVEA.L (A7)+,A6
RTS
***
OPEN_SERIAL
***
CLR.L D1
* A1=ReadRequest
CLR.L D0
LEA SERIALNAME(PC),A0
JSR _LVOOpenDevice(A6)
TST.L D0
RTS
***
DO_Alloc ;Allocate mem for msg ports
***
MOVE.L #$10001,D1
MOVEQ #$52,D0
JMP _LVOAllocMem(A6)
***
GET_MSG ;Get system msg and ack it
***
MOVEA.L mywindow(PC),A0
MOVE.L $56(A0),A0
JSR _LVOGetMsg(A6)
MOVE.L D0,N_M(A4)
BEQ.S GMRTS
MOVE.L D0,A0
MOVE.W $18(A0),D7 NewMessage->Code
* ReplyMsg(NewMessage);
MOVE.L A0,A1
JSR _LVOReplyMsg(A6)
TST.B D7
GMRTS RTS
***
DOCAP ; put captured byte in file
***
TST.B CAPTURE(A4)
BEQ.S DOCAPRET
LEA BUFCAP(A4),A0
MOVE.W CAPCNT(PC),D0
MOVE.B D7,0(A0,D0.W)
ADDQ.W #1,D0
MOVE.W D0,CAPCNT
CMPI.W #CAPSIZE,D0
BNE.S DOCAPRET
***
CAP_FLUSH ;write buffer to disk
***
TST.B CAPTURE(A4)
BEQ.S DOCAPRET
MOVE.L FHCAPT(A4),D1
LEA BUFCAP(A4),A0
MOVE.L A0,D2
CLR.L D3
MOVE.W CAPCNT(PC),D3
JSR _LVOWrite(A5)
CLR.W CAPCNT
TST.L D0
BMI DOMERR1
DOCAPRET RTS
***
CLOSECAP ;Close capture file
***
TST.B CAPTURE(A4)
BEQ.S DOCAPRET
BSR CAP_FLUSH
SF CAPTURE(A4)
MOVE.L FHCAPT(A4),D1
JSR _LVOClose(A5)
LEA CCLOSED(PC),A0
BRA EMITS
***
SEND_BUF_FILL ;Fill transmit buffer
***
MOVE.L FHSEND(A4),D1
LEA BUFSEN(A4),A0
MOVE.L A0,SENPNT(A4)
MOVE.L A0,D2
MOVEQ.L #0,D3
MOVE.W #512,D3
JSR _LVORead(A5)
MOVE.W D0,SENCNT(A4)
BEQ.S CLOSESEND
BMI.S CLOSESEND1
***
GET_SEND_CHAR ;get char from read file
***
SUBQ.W #1,SENCNT(A4)
BMI.S SEND_BUF_FILL
MOVE.L SENPNT(A4),A0
MOVE.B (A0)+,D7
MOVE.L A0,SENPNT(A4)
CMPI.B #$A,D7
BNE.S WRITE1
MOVEQ #$D,D7
***
WRITE1 ;Serial output
***
MOVE.B D7,rs_out(A4)
MOVE.L W_R(A4),A1
JMP _LVODoIO(A6)
CLOSESEND1
BSR DOMERR1
***
CLOSESEND ;Close read file
***
TST.B send(A4)
BEQ.S SENDRTS
MOVE.L FHSEND(A4),D1
JSR _LVOClose(A5)
CLR.B send(A4)
LEA FILESENT(PC),A0
BRA EMITS
SENDRTS RTS
***
DOMERR1 ;Print *** ERROR
***
LEA MERROR(PC),A0
BRA EMITS
***
DELETEPORT ;Free mem used by msg port
***
MOVE.L $E(A0),A2
TST.L $A(A2)
BEQ.S L446D0
MOVE.L A2,A1
JSR _LVORemPort(A6)
L446D0
MOVE.B #-1,8(A2)
MOVEQ #-1,D2
MOVE.L D2,$14(A2)
MOVEQ #0,D0
MOVE.B $F(A2),D0
JSR -$150(A6) FEB0
MOVEQ.L #$22,D0
MOVE.L A2,A1
JMP _LVOFreeMem(A6)
***
DoCreate ;Create a msg port
***
MOVE.L A0,D4
MOVEM.L A2/D5,-(A7)
MOVEQ.L #-1,D0
JSR _LVOAllocSignal(A6)
MOVEQ.L #0,D5
MOVE.B D0,D5
BMI.S SUB0
MOVE.L #$10001,D1
MOVEQ.L #$22,D0
JSR _LVOAllocMem(A6)
MOVEA.L D0,A2
TST.L D0 ??
BNE.S L44670
MOVE.B D5,D0
JSR _LVOFreeSignal(A6)
SUB0
MOVEQ #0,D0
BRA.S L446B2
L44670
MOVE.L D4,$A(A2)
CLR.B 9(A2)
MOVE.B #4,8(A2)
CLR.B $E(A2)
MOVE.B D5,$F(A2)
MOVEQ.L #0,D0
MOVE.L D0,A1
JSR _LVOFindTask(A6)
MOVE.L D0,$10(A2)
TST.L D4
BEQ.S L446A4
MOVE.L A2,A1
JSR _LVOAddPort(A6)
BRA.S L446B0
L446A4
LEA.L $14(A2),A0
MOVE.L A0,(A0)
ADDQ.L #4,(A0)
CLR.L 4(A0)
MOVE.L A0,8(A0)
L446B0
MOVE.L A2,D0
L446B2
MOVEM.L (A7)+,D5/A2
RTS
* SECTION data
bratev DC.W 300,1200,9600
CAPCNT DC.W 0
CX DC.W 0
CY DC.W 14
*struct NewWindow NewWindow =
*{0,0,WD,HT,0,1,
* CLOSEWINDOW|RAWKEY|NEWSIZE,
* WINDOWCLOSE|SMART_REFRESH|ACTIVATE|WINDOWDEPTH|REPORTMOUSE|BORDERLESS,
* NULL, NULL, (title), NULL, NULL,
* 100,35,WD,HT, WBENCHSCREEN,};
NewWindow
DC.W 0,0,WD,HT,1
DC.L $602,$1A0C,0,0
DC.L MTITLE,0,0
DC.W 100,35,WD,HT,1
INTU_LIB DC.B 'intuition.library',0
GRAP_LIB DC.B 'graphics.library',0
MRead_RS DC.B 'Read_RS',0
MWrite_RS DC.B 'Write_RS',0
NEWCLI DC.B 'NEWCLI',0
MHELP DC.B ' BAUD',10,'F1=CAPTURE F2=SEND F3=BAUD F4=MON F6=CLI F10=QUIT',10,0
SENDCAN DC.B 10,'Send Cancelled',10,0
MSEND DC.B 10,'Send:',0
MERROR DC.B '*** Error',10,0
MOPEN DC.B '=OPEN ',0
MCLOSED DC.B '=CLOSED ',0
MCAPTURE DC.B 10,'Capture:',0
CCLOSED DC.B 10,'*** Closed',10,0
MONON DC.B 10,'MON=ON ',0
MONOFF DC.B 10,'MON=OFF ',0
FILESENT DC.B 10,'File Sent',10,0
SERIALNAME DC.B 'serial.device',0
brates DC.B ' 300',0,'1200',0,'9600',0
CTRL DC.B 0
SHIFT DC.B 0
CAPSL DC.B 32
CNOP 0,2
*static char keys[75+75] = {
KEYS
DC.B '`1234567890-=\',0
DC.B '0qwertyuiop[]',0,'123'
DC.B 'asdfghjkl;''',0,0,'456'
DC.B 0,'zxcvbnm',44,'./',0,'.789 '
DC.B 8,10,13,13,27,127,0,0,0,'-'
DC.B '~!@#$%^&*()_+|',0
DC.B '0QWERTYUIOP{}',0,'123'
DC.B 'ASDFGHJKL:"',0,0,'456'
DC.B 0,'ZXCVBNM<>?',0,'.789 '
DC.B 8,10,13,13,27,127,0,0,0,'-'
CNOP 0,2
BSPACE DC.B 8,32,8,0
DOSName DC.B 'dos.library',0
MTITLE DC.B '** P81 081686 ***',0
CNOP 0,2
mywindow DS.L 1
_GfxBase DS.L 1
_IntuitionBase DS.L 1
END